﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace HotelMgr.Models
{
    public class Room
    {
        /// <summary>
        /// 房间号
        /// </summary>
        [DisplayName("房间号"),Key,  DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int RoomID { get; set; }
        /// <summary>
        /// 房间类型ID
        /// </summary>
        [DisplayName("房间类型"), Required]
        public int RoomTypeID { get; set; }
        /// <summary>
        /// 价格
        /// </summary>
        [DisplayName("价格")]
        [Range(0.01,1000)]
        public decimal? RoomPrice { get; set; }

        /// <summary>
        /// 房间状态ID
        /// </summary>
        [DisplayName("房间状态")]
        public int RoomStateID { get; set; }

        /// <summary>
        /// 房间图片URL
        /// </summary>
        [DisplayName("房间图片URL")]
        [StringLength(1024)]
        public string RoomUrl { get; set; }

        /// <summary>
        /// 原价
        /// </summary>
        [NotMapped, DisplayName("原价")]
        public decimal? Price
        {
            get
            {
                if (RoomPrice.HasValue)
                {
                    return RoomPrice;
                }
                else
                {
                    return RoomType.Price;
                }
            }
        }

        #region Navigator Pro
        [ForeignKey("RoomTypeID")]
        public virtual RoomType RoomType { get; set; }

        public virtual RoomState RoomState { get; set; }

        public virtual ICollection<Order> Orders { get; set; }
        #endregion
    }
}